<?php
App::import('Vendor','tcpdf/tcpdf');
ob_end_clean();
$tcpdf = new tcpdf();
$textfont = 'helvetica';

$tcpdf->SetAuthor("RO-MA");
$tcpdf->SetAutoPageBreak(true);
$tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$tcpdf->setPrintHeader(false);
$tcpdf->setPrintFooter(false);
 
$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($textfont,'',8);
$tcpdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); 

$style = array(
    'position' => '',
    'align' => 'C',
    'stretch' => false,
    'fitwidth' => true,
    'cellfitalign' => '',
    'border' => true,
    'hpadding' => 'auto',
    'vpadding' => 'auto',
    'fgcolor' => array(0,0,0),
    'bgcolor' => array(255,255,255),
    'text' => true,
    'font' => 'helvetica',
    'fontsize' => 8,
    'stretchtext' => 2
);
$tcpdf->AddPage('P', 'A4');

//foreach ($service_order_rows as $service_order_row):
  $htmlcontent = '<table style="float:left" border="1" cellspacing="2" cellpadding="0">
                  <tr>
                    <th bgcolor="#cccccc" align="center"><h1>LOGO</h1><br /><br /><h1>RO-MA</h1><br /><br /><br /><br /></th>
                    <th bgcolor="#cccccc" align="center">Documento no válido como factura<br />Tarjetas de seguimiento de cubiertas -Taller de renovación</th>
                    <th bgcolor="#cccccc" align="center">Codigo cubierta:'.$service_order['ServiceOrderRow']['id'].'</th>
                    
                	</tr>
					        <tr>
					            <td bgcolor="#cccccc" align="center" colspan="1">TRABAJO A REALIZAR</td>
					            <td align="center">'.$service_order['ServiceOrderRow']['tipo_de_trabajo'].'</td>
					            <td bgcolor="#cccccc" align="center" colspan="1">FECHA</td>
					        </tr>
					        <tr>
					            <td bgcolor="#cccccc" align="center" colspan="1">OBSERVACIONES</td>
					          	<td align="center">'.$service_order['ServiceOrderRow']['observacion'].'</td>
					            <td align="center">asd</td>
					        </tr>
					        </table>';

		$htmlcontent1 = '<table border="1" cellspacing="2" cellpadding="0">
    		<tr>
        <td width="30%" bgcolor="#cccccc" align="center">Trabajo realizado</td>
        <td width="20%" bgcolor="#cccccc" align="center">Fecha</td>
        <td width="50%" bgcolor="#cccccc" align="center">Comentario</td>
    		</tr>';
		foreach ($service_order_rows as $order):					        
  		$htmlcontent1 = $htmlcontent1.'
    		<tr>
        <td>'.$order['State']['nombre'].'</td>
        <td align="center">'.$order['ServiceOrderRowState']['fecha'].'</td>
        <td>'.$order['ServiceOrderRowState']['comentario'].'</td>
    		</tr>';
		endforeach;
    	$htmlcontent1 = $htmlcontent1.'</table>';
    $htmlcontent = $htmlcontent.'<br /><br /><br />'.$htmlcontent1;
  //$htmlcontent = '<table border="1" cellspacing="2" cellpadding="0"></table>';   
//endforeach;
$tcpdf->writeHTML($htmlcontent);
unset($order);

// output the HTML content
//$tcpdf1->writeHTML($htmlcontent, true, 0, true, 0);
//$tcpdf1->writeHTML($html, true, false, true, false, '');
//$tcpdf1->writeHTML($contenido, true, 0, true, 0);
//$tcpdf1->LastPage();
$tcpdf->Output('miPdf1.pdf', 'I');
?>